﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Rappelz.GameServer.Database;

namespace Rappelz.GameServer
{
    public class takePriority
    {
        public Item.ItemPickupOrder PickupOrder = new Item.ItemPickupOrder();
    }

    public class Item : GameObject
    {
        public enum TargetType : int
        {
            Player = 0,
            Summon = 1,
            Monster = 2,
            NPC = 3,
            Unknown = 4,
        }

        public class ItemPickupOrder
        {
            public uint[] hPlayer = new uint[3];
            public int[] nPartyID = new int[3]; 
        }

        public static Dictionary<int, ItemBaseServer> s_hsItemBase = new Dictionary<int, ItemBaseServer>();
        public static Dictionary<int, string> s_hsItemName = new Dictionary<int, string>();
        public static ItemBaseServer itemServerGold = new ItemBaseServer();


// UserDefinedType: StructItem
// BaseClass      :   GameObject, offset = 0x0
// BaseClass      :     ArObject, offset = 0x0
// 
// UserDefinedType:     iterator
// Function       :     public void GameObject(const struct GameObject &)
// Function       :     public void GameObject::GameObject()
// Function       :     public static struct GameObject::iterator GameObject::get(unsigned int)
// Function       :     public static struct GameObject * GameObject::raw_get(unsigned int)
// Function       :     public bool GameObject::IsCreature()
// Function       :     public bool GameObject::IsPlayer()
// Function       :     public bool GameObject::IsMonster()
// Function       :     public bool GameObject::IsNPC()
// Function       :     public bool GameObject::IsItem()
// Function       :     public bool GameObject::IsSummon()
// Function       :     public bool GameObject::IsPet()
// Function       :     public bool GameObject::IsSkillProp()
// Function       :     public bool GameObject::IsFieldProp()
// Function       :     public bool GameObject::IsRoamer()
// Function       :     protected bool GameObject::IsDeleteable()
// Function       :     protected void GameObject::~GameObject()
// Data           :     this+0xB0, Member, Type: volatile int, m_nRefCount
// Function       :     public struct GameObject & operator=(const struct GameObject &)
// Function       :     public void __local_vftable_ctor_closure()
// Function       :     protected void * __vecDelDtor(unsigned int)
// 
        public static Item AllocItem(long uid, int code, long cnt, ItemInstance.GenerateCode info, int level, int dura,int enhance, int flag, int socket_0, int socket_1, int socket_2, int socket_3, int remain_time, Elemental.Type elemental_effect_type, long elemental_effect_expire_time, int elemental_effect_attack_point, int elemental_effect_magic_point)
        {
            Item item = MemoryPool.AllocItem();

//            InterlockedIncrement(&s_ItemCnt);

            item.m_pItemBase = Item.GetItemBase(code);
            item.m_Instance.UID = uid;
            item.m_Instance.Code = code;
            item.m_Instance.nCount = cnt;

            if ( level == -1 )
                item.m_Instance.nLevel = item.m_pItemBase.nLevel;
            else
                item.m_Instance.nLevel = level;

            if (item.m_Instance.nLevel <= 0 )
                item.m_Instance.nLevel = 1;

            if (dura == -1)
                item.m_Instance.nDurability = item.m_pItemBase.nDurability;
            else
                item.m_Instance.nDurability = dura;

            if ( enhance == -1 )
                item.m_Instance.nEnhance = item.m_pItemBase.nEnhance;
            else
                item.m_Instance.nEnhance = enhance;

            if (item.m_pItemBase.nGroup == 10 && item.m_Instance.nEnhance == 0)
                item.m_Instance.nEnhance = 1;

            item.m_Instance.GenerateInfo = info;
            item.m_Instance.nWearInfo = ItemBase.ItemWearType.WearNone;
            item.m_Instance.OwnerHandle = 0;
            item.m_Instance.nOwnerUID = 0;
            item.m_Instance.Socket[0] = socket_0;
            item.m_Instance.Socket[1] = socket_1;
            item.m_Instance.Socket[2] = socket_2;
            item.m_Instance.Socket[3] = socket_3;
            item.m_Instance.eElementalEffectType = elemental_effect_type;
            item.m_Instance.tElementalEffectExpire = elemental_effect_expire_time;
            item.m_Instance.nElementalEffectAttackPoint = elemental_effect_attack_point;
            item.m_Instance.nElementalEffectMagicPoint = elemental_effect_magic_point;
            item.m_Instance.nCurrentEndurance = item.m_pItemBase.nEndurance;
            item.m_hBindedTarget = 0;
            if (flag == -1 )
                item.m_Instance.Flag = item.m_pItemBase.nInstanceFlag;
            else
                item.m_Instance.Flag = (uint) flag;

            if ( remain_time == -1 )
            {
                if (!item.IsExpireItem())
                    item.m_Instance.tExpire = 0;
                else
                    item.m_Instance.tExpire = item.m_pItemBase.available_time + Globals.Time64();
            }
            else
            {
                if (item.m_pItemBase.decrease_type == 2 )
                    item.m_Instance.tExpire = remain_time;
                else
                    item.m_Instance.tExpire = remain_time + Globals.Time64();
            }
            
            if (item.m_pItemBase.nOptType[0] == 95 )
                item.m_Instance.Flag |= 0x80000000;

            if ((item.m_pItemBase.Flag & (uint)ItemBase.ItemFlag.FlagCanJoin) == 0 && item.m_Instance.Code != 0)
            {
                if (item.m_Instance.nCount > 1)
                    item.m_Instance.nCount = 1;
            }
            return item;
        }

        public static Item FindItem(uint handle)
        {
            return (Item) GameObject.raw_get(handle);
        }
// Function       :   public static struct StructItem * StructItem::AllocGold(const struct StructGold &, enum ItemInstance::GenerateCode)

        public static void InitItemSystem()
        {

        }

        public static void DeInitItemSystem()
        {

        }
        public static void PendFreeItem(Item p)
        {
/*
            int v1; // ebp@0
            unsigned int v2; // eax@2
            ILockVtbl *v3; // eax@3
            StructItem **v4; // ST04_4@3
            unsigned int *v5; // eax@3
            int v6; // ebx@3
            unsigned int *v7; // ST04_4@3
            ILockVtbl *v8; // eax@4
            StructItem *v9; // eax@5
            ItemBaseServer *v10; // ecx@5
            int v11; // esi@6
            StructSummon *v12; // edx@6
            StructPet *v13; // eax@10
            unsigned int v14; // eax@15
            ILockVtbl *v15; // eax@17
            ArSchedulerObject *v16; // ST08_4@18
            ArcadiaServer *v17; // eax@18

            if ( !(_S10 & 1) )
            {
                _S10 |= 1u;
                *(_DWORD *)(v1 - 4) = 0;
                v2 = GetArTime();
                *(_DWORD *)(v1 - 4) = -1;
                prev_proc_time = v2;
            }
            v3 = s_lockForItemDelete.baseclass_0.vfptr;
            *(_DWORD *)(v1 - 16) = 0;
            v3->Lock((ILock *)&s_lockForItemDelete);
            s_lockForItemDelete.baseclass_0.m_pszFileName = "D:\\alienbrainWork\\Source Code\\@Rappelz\\Server\\GameServer_For_Update\\090721_GameServer\\Game\\Struct\\StructItem.cpp : StructItem::PendFreeItem";
            s_lockForItemDelete.baseclass_0.m_nLineNumber = 225;
            *(_DWORD *)(v1 - 20) = &s_lockForItemDelete;
            v4 = s_vPendingItemForDelete._Mylast;
            *(_DWORD *)(v1 - 4) = 1;
            std::_Vector_const_iterator<StateDamage_std::allocator<StateDamage>>::_Vector_const_iterator<StateDamage_std::allocator<StateDamage>>(
            (std::_Vector_const_iterator<unsigned int,std::allocator<unsigned int> > *)(v1 - 52),
            (unsigned int *)v4,
            &s_vPendingItemForDelete.baseclass_0.___u0.baseclass_0);
            std::_Vector_const_iterator<StateDamage_std::allocator<StateDamage>>::_Vector_const_iterator<StateDamage_std::allocator<StateDamage>>(
            (std::_Vector_const_iterator<unsigned int,std::allocator<unsigned int> > *)(v1 - 44),
            (unsigned int *)s_vPendingItemForDelete._Mylast,
            &s_vPendingItemForDelete.baseclass_0.___u0.baseclass_0);
            std::_Vector_const_iterator<StateDamage_std::allocator<StateDamage>>::_Vector_const_iterator<StateDamage_std::allocator<StateDamage>>(
            (std::_Vector_const_iterator<unsigned int,std::allocator<unsigned int> > *)(v1 - 28),
            (unsigned int *)s_vPendingItemForDelete._Myfirst,
            &s_vPendingItemForDelete.baseclass_0.___u0.baseclass_0);
            v5 = *(unsigned int **)(v1 - 24);
            v6 = *(_DWORD *)(v1 - 28);
            v7 = *(unsigned int **)(v1 - 40);
            *(_DWORD *)(v1 - 32) = v5;
            *(_DWORD *)(v1 - 32) = std::_Find<StructQuest_____StructQuest__>(v5, v7, (const unsigned int *)(v1 + 8));
            *(_DWORD *)(v1 - 36) = v6;
            if ( !std::_Vector_const_iterator<X2D::Point<float>_std::allocator<X2D::Point<float>>>::operator__(
            (std::_Vector_const_iterator<ArObject *,std::allocator<ArObject *> > *)(v1 - 36),
            (std::_Vector_const_iterator<ArObject *,std::allocator<ArObject *> > *)(v1 - 52)) )
            {
                v8 = s_lockForItemDelete.baseclass_0.vfptr;
                *(_DWORD *)(v1 - 4) = -1;
                v8->UnLock((ILock *)&s_lockForItemDelete);
                return;
            }
            s_vPendingItemForDelete.Add(p);
            p.bIsDeleteRequested = true;
            v10 = v9->m_pItemBase;
            if (p.nGroup == 13 && (v11 = (int)&v9->m_pSummon, (v12 = v9->m_pSummon) != 0) )
            {
                if ( v12->baseclass_0.baseclass_0.baseclass_0.bIsInWorld )
                    RemovePetFromWorld(*(StructPet **)v11);
            }
            else
            {
                if ( v10->baseclass_0.nGroup != 18 || (v11 = (int)&v9->m_pPet, (v13 = v9->m_pPet) == 0) )
                    goto LABEL_14;
                if ( v13->baseclass_0.baseclass_0.baseclass_0.bIsInWorld )
                    RemovePetFromWorld(*(StructPet **)v11);
            }
            *(_DWORD *)(v1 - 16) = *(_DWORD *)v11;
            LABEL_14:
            ++cnt;
            if ( cnt > 10 )
            {
                cnt = 0;
                v14 = GetArTime();
                if ( prev_proc_time + 100 < v14 )
                {
                    prev_proc_time = v14;
                    StructItem::deletePendingItem();
                }
            }
            v15 = s_lockForItemDelete.baseclass_0.vfptr;
            *(_DWORD *)(v1 - 4) = -1;
            v15->UnLock((ILock *)&s_lockForItemDelete);
            if ( *(_DWORD *)(v1 - 16) )
            {
                v16 = *(ArSchedulerObject **)(v1 - 16);
                RappelzServer.Instance.DeleteObject(v16);
            }
*/
        }
// Function       :   public bool StructItem::IsDeleteable()
        public static bool RegisterItemBase(ItemBaseServer bs)
        {
            if (s_hsItemBase.ContainsKey(bs.nCode))
            {
//                s_hsItemName.[bs.nCode]
/*

                KHash<std::vector<AuctionInfo___std::allocator<AuctionInfo__>>___khash_def::hashPr_mod_basic<int>>::lookup(
                    &s_hsItemCode,
                    (const int *)v2,
                    (unsigned int *)(v1 + 8));
                v3 = std::vector<ItemBaseServer_std::allocator<ItemBaseServer>>::operator__(&s_vItemBase, *(_DWORD *)(v1 + 8));
                ItemBaseServer::operator_(v3, (ItemBaseServer *)v2);
*/
            }
            else
            {
                s_hsItemBase.Add(bs.nCode, bs);
                s_hsItemName.Add(bs.nCode, GameContent.GetString(bs.nNameId));
            }
            return true;
        }
// Function       :   public int GetItemCode()
// Function       :   public static int StructItem::GetItemCode(const char *)

        public static bool IsValidItemCode(int code)
        {
            return s_hsItemBase.ContainsKey(code);
        }
// Function       :   public unsigned int StructItem::GetHandle()

        public override bool IsItem()
        {
            return true;
        }


        public bool IsBow()
        {
            return this.m_pItemBase.nClass == ItemBase.ItemClass.ClassHeavyBow || this.m_pItemBase.nClass == ItemBase.ItemClass.ClassLightBow;
        }


        public bool IsCrossBow()
        {
            return this.m_pItemBase.nClass == ItemBase.ItemClass.ClassCrossBow;
        }
// Function       :   public bool IsBullet()
// Function       :   public bool IsCard()
// Function       :   public bool IsCharm()
// Function       :   public bool IsWeapon()
// Function       :   public bool IsItemCard()
// Function       :   public bool IsWarpItem()
// Function       :   public bool IsSummonCard()
// Function       :   public bool IsPetCage()
// Function       :   public bool IsSkillCard()
// Function       :   public bool IsSpellCard()
// Function       :   public bool IsCube()
// Function       :   public bool IsSupplyItem()

        public bool IsUsingItem()
        {
            return this.m_pItemBase.nType == 6 || this.m_pItemBase.nType == 8;
        }
// Function       :   public bool IsStrikeCube()
// Function       :   public bool IsDefenceCube()
// Function       :   public bool IsSkillCube()
// Function       :   public bool IsRefreshStone()
// Function       :   public bool IsTwoHandItem()
// Function       :   public bool StructItem::IsDonatable()
        public bool IsJoinable()
        {
            return (this.m_pItemBase.Flag & (uint)ItemBase.ItemFlag.FlagCanJoin) != 0;
        }
// Function       :   public bool IsNeedTarget()

        public bool IsCashItem()
        {
            return ((this.m_pItemBase.Flag >> 13) & 1) == 0;
        }
// Function       :   public bool StructItem::IsTradable()
// Function       :   public bool StructItem::IsDropable()

        public bool IsUsableMoving()
        {
            return ((this.m_pItemBase.Flag >> 16) & 1) == 0;
        }

        public bool IsUsableSit()
        {
            return ((this.m_pItemBase.Flag >> 18) & 1) == 0;
        }

        public bool IsUsableInSiegeOrRaid()
        {
            return ((this.m_pItemBase.Flag >> 19) & 1) == 0;
        }

        public bool IsUsableInSecroute()
        {
            return ((this.m_pItemBase.Flag >> 20) & 1) == 0;
        }

        public bool IsUsableInEventmap()
        {
            return ((this.m_pItemBase.Flag >> 21) & 1) == 0;
        }

        public bool IsUsableInHuntaholic()
        {
            return ((this.m_pItemBase.Flag >> 22) & 1) == 0;
        }

        public bool IsUsableInOnlyHuntaholic()
        {
            return ((this.m_pItemBase.Flag >> 23) & 1) != 0;
        }

        public void CopyFrom(Item pFrom)
        {
            uint oldOwner = this.m_Instance.OwnerHandle;
            long oldUID = this.m_Instance.UID;
            this.mv.Copy(pFrom.mv);
            this.m_layer = pFrom.m_layer;

            this.m_Instance.Copy(pFrom.m_Instance);
            this.m_Instance.UID = 0;
            this.m_Instance.nOwnerUID = (int)oldUID;
            this.m_Instance.OwnerHandle = oldOwner;

        }
// Function       :   public const bool ReplaceWith(const int, const bool)

        public string GetName()
        {
            return GameContent.GetString(this.m_pItemBase.nNameId);
        }

        public void SetPickupOrder(Item.ItemPickupOrder ipo)
        {
            for(int i = 0; i < 3; ++i)
            {
                this.m_ItemPickupOrder.hPlayer[i] = ipo.hPlayer[i];
                this.m_ItemPickupOrder.nPartyID[i] = ipo.nPartyID[i];
            }
        }
// Function       :   public const struct StructItem::ITEM_PICKUP_ORDER & GetPickupOrder()
// Function       :   public bool StructItem::SetItemUID(__int64)
// Function       :   public __int64 GetItemUID()
// Function       :   public unsigned int GetOwnerHandle()
        public void SetOwnerInfo(uint handle, int UID, int nAccountID)
        {
            m_Instance.OwnerHandle = handle;
            m_Instance.nOwnerUID = UID;
            m_nAccountID = nAccountID;
            this.m_ItemPickupOrder = new ItemPickupOrder();
        }
// Function       :   public int GetOwnerUID()
// Function       :   public int GetAccountID()
// Function       :   public int GetAuctionID()
// Function       :   public void SetAuctionID(int)
// Function       :   public int GetItemKeepingID()
// Function       :   public void SetItemKeepingID(int)
// Function       :   public void SetIdx(int)
// Function       :   public int GetIdx()
// Function       :   public bool IsVirtualItem()
// Function       :   public void SetVirtualItem()
// Function       :   public void SetOwnSummonInfo(unsigned int, int)
// Function       :   public int GetOwnSummonUID()
// Function       :   public unsigned int GetOwnSummonHandle()
        public bool IsInStorage()
        {
            bool result = false;
            if (this.m_nAccountID != 0 && this.m_Instance.nOwnerUID == 0)
            {
                if (this.m_Instance.Code != 0)
                    result = true;
            }
            return result;
        }

        public bool IsInInventory()
        {
            bool result = false;
            if (this.m_nAccountID == 0)
            {
                if (this.m_Instance.nOwnerUID != 0)
                    result = true;
            }
            return result;
        }
// Function       :   public void SetWearInfo(enum ItemBase::ItemWearType)
// Function       :   public enum ItemBase::ItemWearType GetWearInfo()
// Function       :   public void SetBindedCreatureHandle(unsigned int)
// Function       :   public unsigned int GetBindedCreatureHandle()
        public static ItemBaseServer GetItemBase(int c)
        {
            if (c == 0)
                return itemServerGold;

            if(!s_hsItemBase.ContainsKey(c))
            {
                Globals.Log.Error("ItemBaseServer.GetItemBase failed to find an item. Code [{0}]",c);
                return itemServerGold;
            }
            return s_hsItemBase[c];
        }
        
        public ItemBaseServer GetItemBase()
        {
            return m_pItemBase;
        }

        public float GetWeight()
        {
            return this.m_pItemBase.fWeight * (float)this.m_Instance.nCount;
        }

        public float GetWeight(long cnt)
        {
            return this.m_pItemBase.fWeight * cnt;
        }
// Function       :   public enum ItemBase::ItemClass GetItemClass()

        public bool IsWearable()
        {
            bool result;

            if (GetWearType() == ItemBase.ItemWearType.WearCantWear)
                result = false;
            else
                result = (~((m_Instance.Flag) >> 3) & 1) != 0;
            return result;

        }

        public ItemBase.ItemWearType GetWearType()
        {
            return m_pItemBase.WearType;
        }

        public int GetUsingSocketCount()
        {
            int result = 0;

            if (this.m_pItemBase.nSocketCount > 0)
            {
                for (int i = 0; i < 4; ++i)
                {
                    if (this.m_Instance.Socket[i] != 0)
                        result++;
                }
            }
            return result;
        }
// Function       :   public int GetSocketCode(unsigned int)
// Function       :   public void SetSocketCode(unsigned int, int)
// Function       :   public int GetSummonCode()
// Function       :   public int GetStateCode()
// Function       :   public int GetStateLevel()
// Function       :   public unsigned long GetStateTime()
// Function       :   public unsigned long GetCoolTime()
// Function       :   public int GetCoolTimeGroup()
// Function       :   public void SetSummonSID(int)
// Function       :   public int GetSummonSID()
// Function       :   public void SetSummonStruct(struct StructSummon *)
// Function       :   public struct StructSummon * GetSummonStruct()
// Function       :   public void SetPetSID(const int)
// Function       :   public const int GetPetSID()
// Function       :   public void SetPetCode(const int)
// Function       :   public const int GetPetCode()
// Function       :   public void SetPetStruct(struct StructPet *)
// Function       :   public struct StructPet * GetPetStruct()
// Function       :   public void SetEventDropFlag(bool)
// Function       :   public bool GetEventDropFlag()
// Function       :   public int GetSkillId()
// Function       :   public bool IsBinded()

        public void SetBindTarget(Creature creature)
        {
            if (creature != null && creature.IsPlayer())
                this.m_Instance.Socket[0] = creature.GetSID();
            else
                this.m_Instance.Socket[0] = 0;
            if (creature != null && creature.IsSummon())
                this.m_Instance.Socket[1] = creature.GetSID();
            else
                this.m_Instance.Socket[1] = 0;
            if (creature != null)
                m_hBindedTarget = creature.GetHandle();
            else
                m_hBindedTarget = 0;
            m_bIsNeedUpdateToDB = true;

        }
// Function       :   public int GetBindedPlayerSID()
// Function       :   public int GetBindedSummonSID()
// Function       :   public bool IsGold()
        public void SetCount(long new_count)
        {
            m_Instance.nCount = new_count;
            m_bIsNeedUpdateToDB = true;
        }
// Function       :   public const __int64 GetCount()

        public int GetItemRank()
        {
            return this.m_pItemBase.nRank;
        }
// Function       :   public int GetItemLevel()
// Function       :   public void SetItemLevel(int)
// Function       :   public int GetItemEnhance()
// Function       :   public void SetItemEnhance(int)
// Function       :   public int GetCurrentEndurance()
        public void SetCurrentEndurance(int n)
        {
            int maxendurance = GetMaxEndurance();
            m_Instance.nCurrentEndurance = n;
            if (n > maxendurance)
                m_Instance.nCurrentEndurance = maxendurance;
            if (m_Instance.nCurrentEndurance < 0 )
                m_Instance.nCurrentEndurance = 0;
            m_bIsNeedUpdateToDB = true;
        }
        
        public int GetMaxEndurance()
        {
            int result = 0;

            if (this.m_pItemBase.nSocketCount != 0)
            {
                if (this.m_pItemBase.nSocketCount <= 0 )
                    return this.m_pItemBase.nEndurance;

                int total_endurance = 0;
                for (int i = 0; i < this.m_pItemBase.nSocketCount; ++i)
                {
                    if(this.m_Instance.Socket[i] != 0)
                    {
                        total_endurance += Item.GetItemBase(this.m_Instance.Socket[i]).nEndurance;
                    }
                }
                if (total_endurance != 0)
                    result = total_endurance;
                else
                    result = this.m_pItemBase.nEndurance;
            }
            else
            {
                result = this.m_pItemBase.nEndurance;
            }
            return result;

        }

        public int GetLevelLimit()
        {
            return GameRule.GetItemLevelLimit(m_pItemBase.nRank);
        }
// Function       :   public int GetRecommendLevel()
// Function       :   public float GetItemAttackRange()
// Function       :   public int GetItemGroup()
// Function       :   public struct XFlag<int,1> StructItem::GetBaseFlag()
// Function       :   public const struct XFlag<int,1> & GetInstanceFlag()
// Function       :   public struct XFlag<int,1> & GetInstanceFlag()

        public bool IsQuestItem()
        {
            return (this.m_pItemBase.Flag & (int)ItemBase.ItemFlag.FlagQuest) != 0;
        }
// Function       :   public bool StructItem::IsQuestDistributeItem()
// Function       :   public enum ItemInstance::GenerateCode GetGenerateCode()
        public bool IsExpireItem()
        {
            sbyte dt = m_pItemBase.decrease_type;
            return dt == 1 || dt == 2;
        }
// Function       :   public __int64 GetExpireTime()
// Function       :   public void SetRemainTime(__int64)
// Function       :   public const unsigned short StructItem::SetElementalEffect(const enum Elemental::Type &, const __int64 &)
// Function       :   public const unsigned short StructItem::SetElementalEffectAttackPoint(const int)
// Function       :   public const unsigned short StructItem::SetElementalEffectMagicPoint(const int)
// Function       :   public void StructItem::ClearElementalEffect()
        public Elemental.Type GetElementalEffectType()
        {
            Elemental.Type result;
            if (this.m_Instance.tElementalEffectExpire < Globals.Time64())
                result = 0;
            else
                result = this.m_Instance.eElementalEffectType;
            return result;
        }
// Function       :   public const __int64 & GetElementalEffectExpireTime()
// Function       :   public const int GetElementalEffectAttackPoint()
// Function       :   public const int GetElementalEffectMagicPoint()
// Function       :   public volatile unsigned int GetDBQueryCount()
// Function       :   public bool IsNeedUpdateToDB()
// Function       :   public void TurnOffDbUpdateFlag()
// Function       :   public void TurnOnUpdateFlag()
// Function       :   public void SetStorageIndex(unsigned int)
// Function       :   public unsigned int GetStorageIndex()
// Function       :   public void SetDropTime(unsigned long)
// Function       :   public unsigned long GetDropTime()
// Function       :   public int GetSetItemID()
// Function       :   public int GetSetItemPartFlag()
// Function       :   protected static void StructItem::deletePendingItem()
// Function       :   protected static void StructItem::freeItem(struct StructItem *)
// Function       :   protected bool StructItem::ProcDelete()
//        public uint m_hHandle;                                        // 0xB8
        public ItemInstance m_Instance = new ItemInstance();                                 // 0xC0
        public int m_nAccountID;                                        // 0x140
        public uint m_unInventoryIndex;                                 // 0x144
        public bool m_bIsEventDrop;                                     // 0x148
        public bool m_bIsVirtualItem;                                   // 0x149
        public bool m_bIsNeedUpdateToDB;                                // 0x14A
        public ItemBaseServer m_pItemBase;                              // 0x14C
        public Summon m_pSummon;                                        // 0x150
        public Pet m_pPet;                                              // 0x154
        public uint m_hBindedTarget;                                    // 0x158
        public uint m_nDropTime;                                        // 0x15C
        public ItemPickupOrder m_ItemPickupOrder = new ItemPickupOrder();   // 0x160
// Data           :   this+0x178, Member, Type: class XCriticalSection, m_bQueryLock
//        public Queue<IDBProc> m_lQueryList = new Queue<IDBProc>();            // 0x1B8

        public override string ToString()
        {
            return "Item: " + GameContent.GetString(this.m_pItemBase.nNameId);
        }

    }
}
